package com.txazo.action;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.txazo.action.base.ActionBase;
import com.txazo.domain.User;
import com.txazo.service.UserService;

/**
 * 用户注册Action
 * 
 * @author txazo
 * @since 1.0
 */
@Controller
@Scope("session")
public class RegisterAction extends ActionBase {

	private static final long serialVersionUID = 1L;

	private String username;
	private String password;

	@Autowired
	private UserService userService;

	public String register() throws Exception {
		User user = new User(username, password);

		User register = userService.register(user);
		if (register != null) {
			session.put("user", register);
			return SUCCESS;
		}
		return INPUT;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

}